package com.car.Test;

import com.car.dao.CarDao;
import com.car.dao.impl.CarDaoImpl;
import com.car.domain.Car;
import org.junit.Test;

import java.util.List;

public class CarDaoImplTest {
   private static final CarDao CAR_DAO=new CarDaoImpl();
    @Test
    public void add() throws Exception {
        Car car=new Car();
        car.setName("m3");
        car.setBrand("宝马");
        car.setCarNum("888");
        car.setColor("黑金色");
        car.setEmployeeId(1);
        car.setType("轿跑");
        car.setPrice(500000.0);
        CAR_DAO.add(car);
    }

    @Test
    public void delete() throws Exception {
        int delete=CAR_DAO.delete(1);
    }

    @Test
    public void update() throws Exception {
        Car car=CAR_DAO.queryById(1);
        car.setName("m5");
        CAR_DAO.update(car);
    }

    @Test
    public void queryById() throws Exception {
        Car car=CAR_DAO.queryById(1);
        System.out.println(car);
    }

    @Test
    public void queryAll() throws Exception {
        List<Car> cars = CAR_DAO.queryAll();
        System.out.println(cars);
    }
}